﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


namespace Unity.Game.ElisAdvance.ElisScript
{
    //玩家elis引入事件
    public class ElisState_Stand
    {

        public static void onFixedProc(ElisActiveObject activeObject, float horiztantlKey)
        {

            if (KeyPressEvent.isKeyPressDownDash())
            {
                activeObject.clearStateVector();
                activeObject.pushStateVector(0);
                activeObject.setState(State.STATE_DASH);

            }

            else if (KeyPressEvent.isKeyPressDown())
            {
                activeObject.clearStateVector();
                activeObject.pushStateVector(0);
                activeObject.setState(State.STATE_SIT);
                return;
            }
            else if (KeyPressEvent.isKeyPressDownJump())
            {
                activeObject.clearStateVector();
                activeObject.pushStateVector(0);
                activeObject.setState(State.STATE_JUMP);
                return;
            }
            else if (KeyPressEvent.isKeyPressDownAttack())
            {
                activeObject.clearStateVector();
                activeObject.pushStateVector(0);
                activeObject.setState(State.STATE_ATTACK);
                return;
            }
            else if (horiztantlKey != 0.0f || KeyPressEvent.isKeyPressLeft() || KeyPressEvent.isKeyPressLeft())
            {
                activeObject.setState(State.STATE_MOVE);
                return;
            }

        }

        public static void onProc(ElisActiveObject activeObject)
        {
            /*
            if (Com.checkObjectTime(activeObject, "GLOBAL_JumpLandTimeEvent", 0.1f) && !activeObject.isLand())
            {

                activeObject.setCurrentPos(
                    Com.getDistancePos(activeObject.getXPos(), activeObject.getDirection(), 0.1f),
                    activeObject.getYPos());

                activeObject.clearStateVector();
                activeObject.pushStateVector(2);
                activeObject.setState(State.STATE_JUMP);
                return;
            }
            */
        }

        public static void onSetState(ElisActiveObject activeObject)
        {

            activeObject.getGravityEvent().setEnable(false);
            activeObject.setAngleRotate(0.0f);
            activeObject.getAniManager().setAni("Idle");
            activeObject.setXVelocity(0.0f);
            activeObject.setYVelocity(0.0f);
            activeObject.getVar("GLOBAL_horiztantlKey").clear_vector();
            activeObject.setCurrentPos(activeObject.getXPos(), activeObject.getYPos() - 0.05f);

            activeObject.getVar("JumpDashFlag").clear_vector();
            activeObject.getVar("JumpDashFlag").push_vector(0);

            activeObject.getVar("JumpAttackFlag").clear_vector();
            activeObject.getVar("JumpAttackFlag").push_vector(0);


        }

    }
}